1. Field of Invention
The present invention relates generally to exception handling, and specifically to providing a nonstandard desired response to the occurrence of an exceptional situation during a computation.
2. Background of Invention
When a computation is performed on a computing system, typically a result or return value can be generated. For example, in the case of a divide operation, the result will be the quotient. Exceptional situations can occur during the course of a computation. For example, an attempt can be made to divide by zero during a divide operation, the result of which is undefined in mathematics. Many computing systems are configured to produce certain default results when an exceptional situation arises during the course of a computation. For example, on a floating-point arithmetic engine that conforms to the Institute of Electrical and Electronics Engineers (IEEE) Standard for Binary Floating-Point Arithmetic, when both the dividend and the divisor of a divide operation are zero, the default quotient produced is a special value called NaN, which stands for Not a Number.
Under some circumstances, the default result for an exceptional situation that arises during the course of a computation can be appropriate. However, in some cases the default result produced when an exceptional situation arises is not appropriate for the computation being performed. Consider, for example, computing the value of (sin x)/x. As x approaches zero, the mathematical value of this equation approaches one, not some special value such as NaN.
It would be desirable to be able to specify a nonstandard value to be returned, should a specific exceptional situation arise during the course of a computation. Because desired results can be a function of dynamic circumstances such as the application or operating environment in which the computation is occurring, it would be further desirable to be able to specify and dynamically change the return values for computations during which specific exceptional situations occur. It will sometimes be desirable to use the default value, so selection thereof should be possible. What is needed are systems and methods to dynamically specify and modify results to be produced when specific exceptional situations occur during the course of computations.